package com.workflow.workflowproject.entity.table;

import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.table.TableDef;

import java.io.Serial;

/**
 *  表定义层。
 *
 * @author sht05
 * @since 2024-11-04
 */
public class FlowLogsTableDef extends TableDef {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 
     */
    public static final FlowLogsTableDef FLOW_LOGS = new FlowLogsTableDef();

    /**
     * 流程日志ID
     */
    public final QueryColumn ID = new QueryColumn(this, "id");

    /**
     * 业务ID
     */
    public final QueryColumn BUS_KEY = new QueryColumn(this, "bus_key");

    /**
     * 审批结果
     */
    public final QueryColumn RESULT = new QueryColumn(this, "result");

    /**
     * 审批人员ID
     */
    public final QueryColumn USER_ID = new QueryColumn(this, "user_id");

    /**
     * 节点key
     */
    public final QueryColumn NODE_KEY = new QueryColumn(this, "node_key");

    /**
     * 流程名称
     */
    public final QueryColumn TASK_NAME = new QueryColumn(this, "task_name");

    /**
     * 创建时间
     */
    public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");

    /**
     * 修改时间
     */
    public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");

    /**
     * 流程ID
     */
    public final QueryColumn PROCESS_INSTANCE_ID = new QueryColumn(this, "process_instance_id");

    /**
     * 所有字段。
     */
    public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");

    /**
     * 默认字段，不包含逻辑删除或者 large 等字段。
     */
    public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, BUS_KEY, PROCESS_INSTANCE_ID, NODE_KEY, TASK_NAME, USER_ID, RESULT, CREATE_TIME, UPDATE_TIME};

    public FlowLogsTableDef() {
        super("", "t_com_flow_logs");
    }

    private FlowLogsTableDef(String schema, String name, String alisa) {
        super(schema, name, alisa);
    }

    public FlowLogsTableDef as(String alias) {
        String key = getNameWithSchema() + "." + alias;
        return getCache(key, k -> new FlowLogsTableDef("", "t_com_flow_logs", alias));
    }

}
